﻿#ifndef _SHELL_GAME_NET_H_
#define _SHELL_GAME_NET_H_

#include "Message.h"
#include "cocos2d.h"

using namespace cocos2d;
using namespace std;

// 64m is enough
#define BUFF_SIZE 67108864


// msg structure
// len | id | data
// len = id.size() + data.size()
class GameNet
{
public:
	GameNet(string& ip, int port);
	virtual ~GameNet();
	void static close();
	static int conn(string& ip, int port);
	static bool reconn(string& ip, int port);//重新连接
private:
	static GameNet* instance;
	static std::string ip;
	static int port;
	static int fd;
	static void* buf;
	static bool connect(string& ip, int port);
	bool init();
};

#endif
